<template>
	<form method="get">
		<p>查找的id: <input type="text" v-model="searchForm.sno" name="sno" style="width: 150px;border-color: black" /></p>
		<input type="button" value="查找" @click="search()" />
	</form>

	<form method="get">
		<p>删除的id: <input type="text" v-model="deleteForm.sno" name="sno" style="width: 150px;border-color: black" /></p>
		<input type="button" value="删除" @click="del()" />
	</form>

	<form method="get">
		<p>姓名: <input type="text" v-model="addForm.sname" name="sname" style="width: 150px;border-color: black" /></p>
		<p>性别: <input type="text" v-model="addForm.ssex" name="ssex" style="width: 150px;border-color: black" /></p>
		<p>年龄: <input type="text" v-model="addForm.sage" name="sage" style="width: 150px;border-color: black" /></p>
		<p>系别: <input type="text" v-model="addForm.sdept" name="sdept" style="width: 150px;border-color: black" /></p>
		<p>班级: <input type="text" v-model="addForm.sclass" name="sclass" style="width: 150px;border-color: black" /></p>
		<p>电话: <input type="text" v-model="addForm.stelephone" name="stelephone" style="width: 150px;border-color: black" /></p>
		<input type="button" value="添加" @click="add()" />
	</form>

	<form method="get">
		<p>id: <input type="text" name="sno" v-model="updateForm.sno" style="width: 150px;border-color: black" /></p>
		<p>姓名: <input type="text" name="sname" v-model="updateForm.sname" style="width: 150px;border-color: black" /></p>
		<p>性别: <input type="text" name="ssex" v-model="updateForm.ssex" style="width: 150px;border-color: black" /></p>
		<p>年龄: <input type="text" name="sage" v-model="updateForm.sage" style="width: 150px;border-color: black" /></p>
		<p>系别: <input type="text" name="sdept" v-model="updateForm.sdept" style="width: 150px;border-color: black" /></p>
		<p>班级: <input type="text" name="sclass" v-model="updateForm.sclass" style="width: 150px;border-color: black" /></p>
		<p>电话: <input type="text" name="stelephone" v-model="updateForm.stelephone" style="width: 150px;border-color: black" /></p>
		<input type="button" value="更新" @click="update()" />
	</form>
</template>

<script>
	export default {
		data() {
			return {
				searchForm: {
					sno: "",
				},
				deleteForm: {
					sno: "",
				},
				addForm: {
					sname: "",
					ssex: "",
					sage: "",
					sdept: "",
					sclass: "",
					stelephone: "",
				},
				updateForm: {
					sno: "",
					sname: "",
					ssex: "",
					sage: "",
					sdept: "",
					sclass: "",
					stelephone: "",
				},
			}
		},
		methods: {
			async search() {
				const {
					data: res
				} = await this.$http.get("student/selectOne?sno=" + this.searchForm.sno);
				this.$alert(res, '查询结果', {
					confirmButtonText: '确定',
				});
			},
			async del() {
				const {
					data: res
				} = await this.$http.get("student/deleteOne?sno=" + this.deleteForm.sno);
				if (res) {
					this.$alert("删除成功", '删除结果', {
						confirmButtonText: '确定',
					});
				} else {
					this.$alert("删除失败", '删除结果', {
						confirmButtonText: '确定',
					});
				}

			},
			async add() {
				const {
					data: res
				} = await this.$http.get("student/addOne?", {
					params: this.addForm
				});
				this.$alert(res, '添加结果', {
					confirmButtonText: '确定',
				});
			},
			async update() {
				const {
					data: res
				} = await this.$http.get("student/updateOne?", {
					params: this.updateForm
				});
				this.$alert(res, '更新结果', {
					confirmButtonText: '确定',
				});
			},
		},
	}
</script>

<style>
</style>
